import Ajax from './ajax';

const Request = {
  User: {
    info() {
      return Ajax.get('/user/getUserInfo');
    }
  },
  Dict: {
    get() {
      return Ajax.get(`/dict`);
    }
  },
  Home: {
    getMessageList() {
      return Ajax.get(`/home/messages`);
    }
  },
  System: {
    updateMenu(param) {
      return Ajax.put(`/sys/menu`, param);
    },
    addMenu(param) {
      return Ajax.post(`/sys/menu`, param);
    },
    removeMenu(id) {
      return Ajax.delete(`/sys/menu/`+id)
    },
    updateDept(param) {
      return Ajax.put(`/dept`, param);
    },
    addDept(param) {
      return Ajax.post(`/dept`, param);
    },
    removeDept(id) {
      return Ajax.delete(`/dept/`+id)
    },
    updateRole(param) {
      return Ajax.put(`/role`, param);
    },
    addRole(param) {
      return Ajax.post(`/role`, param);
    },
    removeRole(id) {
      return Ajax.delete(`/role/`+id)
    }
  },
  Account: {
    menus() {
      return Ajax.get("/sys/menu");
    },
    saveAccount(param) {
      return Ajax.put("/user/save", param);
    },
    updateAccount(param) {
      return Ajax.put("/user/update", param);
    },
    saveRoleConfig(param) {
      return Ajax.put("/management/role_config", param);
    },
    removeUsers(ids) {
      return Ajax.delete("/management/user/"+ids)
    }
  },
  Login: {
    login(param) {
      return Ajax.postJson('/login', param);
    },
    logout(param) {
      return Ajax.post('/logout', param);
    }
  },
  Management: {
    users(params) {
      return Ajax.get('/management/users', params);
    },
    roles(params) {
      return Ajax.get('/management/roles', params);
    },
    depts(params) {
      return Ajax.get('/dept', params);
    },
  }
};

export default Request;
